package com.nathan.crm.controller;

import com.nathan.base.BaseController;
import com.nathan.crm.query.CustomerQuery;
import com.nathan.crm.service.ReportService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;
import java.util.Map;

@Controller
@RequestMapping("report")
public class ReportController extends BaseController {

    @Autowired
    private ReportService reportService;

    @RequestMapping("index/{type}")
    public String index(@PathVariable("type") Integer type){
        switch (type){
            case 0:
                return "report/customer_contri";
            case 1:
                return "report/customer_make";
            case 2:
                return "report/customer_serve";
            case 3:
                return "report/customer_loss";
            default:
                return "";
        }
    }

    /**
     * 查询客户贡献
     * @param customerQuery
     * @return
     */
    @RequestMapping("queryCustomerContributionByParams")
    @ResponseBody
    public Map<String,Object> queryCustomerContribution(CustomerQuery customerQuery){
        return reportService.queryCustomerContribution(customerQuery);
    }

    /**
     * 柱状图：查询客户构成（各个级别的客户的数量）
     * @return
     */
    @RequestMapping("countCustomerMake")
    @ResponseBody
    public Map<String,Object> countCustomerLevel(){
        return reportService.countCustomerLevel();
    }

    @RequestMapping("countCustomerMake02")
    @ResponseBody
    public List<Map<String,Object>> countCustomerLevel2(){
        return reportService.countCustomerLevel2();
    }

}
